#ifndef GXFR_PHYSX_WRAPPERS_H
#define GXFR_PHYSX_WRAPPERS_H

#define NOMINMAX
#include "Basic/GxLibBasic.h"
#include "NxFoundation.h"
#include "NxStream.h"
#include "Basic/Stream.h"

namespace FinalRendering
{
	namespace Engine
	{
		namespace Physics
		{
			using namespace GxLibBasic;

			class StreamWrapper : public NxStream
			{
			private:
				Stream * s;
			public:

				StreamWrapper(Stream * stream);

				virtual		NxU8			readByte()								const	;
				virtual		NxU16			readWord()								const	;
				virtual		NxU32			readDword()								const	;
				virtual		NxF32			readFloat()								const	;
				virtual		NxF64			readDouble()							const	;
				virtual		void			readBuffer(void* buffer, NxU32 size)	const	;

				virtual		NxStream&		storeByte(NxU8 b)								;
				virtual		NxStream&		storeWord(NxU16 w)								;
				virtual		NxStream&		storeDword(NxU32 d)								;
				virtual		NxStream&		storeFloat(NxF32 f)								;
				virtual		NxStream&		storeDouble(NxF64 f)							;
				virtual		NxStream&		storeBuffer(const void* buffer, NxU32 size)		;

			};

			class UserAllocator : public NxUserAllocator
			{    
			public:        
				void * malloc(NxU32 size)
				{            
					return ::malloc(size);
				}        
				
				void * mallocDEBUG(NxU32 size,const char *fileName, int line)
				{            
					return ::_malloc_dbg(size,_NORMAL_BLOCK, fileName, line);
				}
				void * realloc(void * memory, NxU32 size)
				{
					return ::realloc(memory,size);
				}        
				void free(void * memory)
				{ 
					::free(memory);
				} 
			};
		}
	}
}

#endif